home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Storage / Bento / CM / CMAPIEnv.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  9.3 KB  |  237 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CMAPIEnv.h
  3.  
  4.     Contains:    Container Manager API Environment Specific Definitions
  5.  
  6.     Written by:    Ira L. Ruben
  7.  
  8.     Owned by:    Ed Lai
  9.  
  10.     Copyright:    © 1992 - 1996 by Apple Computer, Inc., all rights reserved.
  11.  
  12.     Change History (most recent first):
  13.  
  14.          <4>     8/20/96    DH        Mergecontainers is now back on.
  15.          <3>     8/19/96    DH        376276:OpenDoc corrupts document when
  16.                                     running out of disk space. Mergecontainers
  17.                                     is now on.
  18.          <2>     1/15/96    TJ        Cleaned Up
  19.          <3>     1/19/95    VL        1183685: Turned on Merge Container flag.
  20.          <2>     8/26/94    EL        #1182308 Make endian flag platform
  21.                                     independent
  22.          <3>     3/17/94    EL        Add endian-ness flag #1149979
  23.  
  24.     To Do:
  25. */
  26.  
  27. /* (use tabs = 2 to view this file correctly) */
  28. /*---------------------------------------------------------------------------*
  29.  |                                                                           |
  30.  |                       <<< CM_API_Environment.h >>>                        |
  31.  |                                                                           |
  32.  |           Container Manager API Environment Specific Definitions          |
  33.  |                                                                           |
  34.  |                               Ira L. Ruben                                |
  35.  |                                  4/27/92                                  |
  36.  |                                                                           |
  37.  |                    Copyright Apple Computer, Inc. 1992-1994               |
  38.  |                           All rights reserved.                            |
  39.  |                                                                           |
  40.  *---------------------------------------------------------------------------*
  41.  
  42.  This file is included by CM_API.h and is intended to contain site-specific and compiler-
  43.  specific stuff that should be defined for the particular installation which is used to
  44.  compile the Container Manager code and the user's API calls.  People responsible for
  45.  installing the Container Manager on specific environments are EXPECTED to change this
  46.  file.
  47.  
  48.  The stuff here is assumed to be global macros utilized by the API and the Container
  49.  Manager code itself.
  50.  
  51.  
  52.                                               *------------------------------*
  53.                                                 | NOTE TO DOS (80x86) USERS... |
  54.                                                 *------------------------------*
  55.  
  56.  The Container Manager should be compiled with the "large" memory model so that all
  57.  routines, pointers, etc. are "far".  All external API interfaces are appropriately
  58.  qualified this way.  Since handlers are implementation or user dependent, these files
  59.  must be compiled with the large memory model.  The only exception is local static
  60.  routines which usually can be qualified with "near" (except, of course, for handlers).
  61. */
  62.  
  63. #ifndef __CM_API_ENV__
  64. #define __CM_API_ENV__
  65.  
  66. #ifndef MergeContainersAvailable
  67. #define MergeContainersAvailable    1
  68. #endif
  69.  
  70.  
  71. /*--------------------------*
  72.  | Target Machines Switches |
  73.  *--------------------------*
  74.  
  75.  If there are machine specific definitions, define an appropriate macro switch here...
  76. */
  77.  
  78. #ifndef CM_80x86                                                            /* 1 if target is x86 machine                            */
  79. #define CM_80x86     0
  80. #endif
  81.  
  82. #if CM_80x86
  83. #define kCMDefaultEndian 0x0101U
  84. #else
  85. #define kCMDefaultEndian 0x0000U
  86. #endif
  87.  
  88. /*--------------------------*
  89.  | Target Compiler Switches |
  90.  *--------------------------*
  91.  
  92.  If there are compiler specific definitions, define an appropriate macro switch here...
  93. */
  94.  
  95. #ifndef CM_MICROSOFT
  96. #define CM_MICROSOFT     0                                /* 80x86 machines using Microsoft DOS compilers        */
  97. #endif
  98.  
  99. #ifndef CM_BORLAND
  100. #define CM_BORLAND         0                                /* 80x86 machines using Borland DOS compilers            */
  101. #endif
  102.  
  103. #ifndef CM_ZORTECH
  104. #define CM_ZORTECH         0                                /* 80x86 machines using Zortech DOS compilers            */
  105. #endif
  106.  
  107. #ifndef CM_MPW                                                /* Macintosh MPW C compiler/environment                        */
  108. #define CM_MPW                 0
  109. #endif
  110.  
  111.  
  112. /*----------*
  113.  | #pragmas |
  114.  *----------*
  115.  
  116.  Environment #pragmas should go here.  Remember this file is included to build the
  117.  Container Manager too!
  118. */
  119.  
  120.  
  121. /*-------------------------------*
  122.  | Compiler Specific Definitions |
  123.  *-------------------------------*
  124.  
  125.  The following are used in to modify the source to satisfy the "peculiarities" of various
  126.  compilers used to compile the Container Manager.
  127. */
  128.  
  129. /* Compilers in 80x86 environments define the "size" of pointers as a function of the     */
  130. /* memory modes used.  In these environments, it is assumed and required that the             */
  131. /* Container Manager code is ALWAYS compiled with a "large" memory module.  The                 */
  132. /* following define common names to use for the keywords that control pointer sizes:        */
  133.  
  134. #if CM_MICROSOFT
  135. #define CM_NEAR _near                                    /* the "near" keyword for Microsoft C                            */
  136. #define CM_FAR  _far                                    /* the "far" keyword for Microsoft C                            */
  137. #elif CM_BORLAND
  138. #define CM_NEAR near                                    /* the "near" keyword for Borland C                                */
  139. #define CM_FAR  far                                        /* the "far" keyword for Borland C                                */
  140. #elif CM_ZORTECH
  141. #define CM_NEAR near                                    /* the "near" keyword for Zortech C                                */
  142. #define CM_FAR  far                                        /* the "far" keyword for Zortech C                                */
  143. #else
  144. #define CM_NEAR
  145. #define CM_FAR
  146. #endif
  147.  
  148. /* Microsoft, Borland, and Zortech DOS C compilers support multiple linkage conventions.*/
  149. /* In particular, C and Pascal conventions.  As it turns out, in general, the Pascal        */
  150. /* calling conventions are more efficient than the C conventions for these compilers.      */
  151. /* But Pascal calling conventions cannot be used when there are "..." (variable number     */
  152. /* of) arguments.  So the following allow for overriding the default calling                         */
  153. /* conventions:                                                                                                                                                    */
  154.  
  155. #ifndef CM_C
  156. #if CM_MICROSOFT
  157. #define CM_C             _cdecl                            /* the "cdecl" keyword for Microsoft C                        */
  158. #elif CM_BORLAND
  159. #define CM_C             cdecl                                /* the "cdecl" keyword for Borland C                            */
  160. #elif CM_ZORTECH
  161. #define CM_C             cdecl                                /* the "cdecl" keyword for Zortech C                            */
  162. #else
  163. #define CM_C                                                     /* no override provided for C calling conventions    */
  164. #endif
  165. #endif
  166.  
  167. #ifndef CM_PASCAL
  168. #if CM_MICROSOFT
  169. #define CM_PASCAL _pascal                            /* the "pascal" keyword for Microsoft C                        */
  170. #elif CM_BORLAND
  171. #define CM_PASCAL pascal                            /* the "pascal" keyword for Borland C                            */
  172. #elif CM_ZORTECH
  173. #define CM_PASCAL pascal                            /* the "pascal" keyword for Zortech C                            */
  174. #else
  175. #define CM_PASCAL                                         /* no override provided for Pascal                                */
  176. #endif
  177. #endif
  178.  
  179. /* Note: Because default linkage conventions are usually a function of the options            */
  180. /*             specified to the compiler, the C and Pascal macros may also be controlled from    */
  181. /*              the options.  Hence the #ifndef's.                                                                                            */
  182.  
  183. /* Finally, the API user doesn't want know or care how the Container Manager is built.    */
  184. /* Nor should the user care what linkage conventions are being used. So the API headers */
  185. /* use the following and more generic attributes of the functions and pointers to                */
  186. /* explicitly override whatever memory model the user is using.  These attributes fall    */
  187. /* into three classes:                                                                                                                                    */
  188.  
  189. /*        1. Pointer sizes: CM_PTR                                                                                                                    */
  190.  
  191. /*             Since the Container Manager is built with the large memory model in 80x86            */
  192. /*             environments, all pointers are "far" pointers.                                                                 */
  193.  
  194. /*        2. Functions that take a variable number of arguments: CM_VARARGS                                    */
  195.  
  196. /*             This is a unique class of functions since the calling conventions for these        */
  197. /*             functions may be different from those with a fixed number of arguments.  For        */
  198. /*             example, in Microsoft, C calling conventions must be used here while the more    */
  199. /*             efficient Pascal calling conventions can be used for functions with a fixed        */
  200. /*             number of arguments (which is class 3).                                                                                */
  201.  
  202. /*        3. Functions that take a fixed number of arguments: CM_FIXEDARGS                                    */
  203.  
  204. /*             API functions that take a fixed number of arguments are given this attribute.    */
  205. /*             This allows the Container Manager builder to use different calling conventions    */
  206. /*             from those used for functions that take a variable number of arguments.                */
  207.  
  208. #define CM_PTR             CM_FAR                        /* pointer attribute                                                            */
  209. #define CM_VARARGS     CM_FAR CM_C             /* variable nbr of arguments function attribute        */
  210. #define CM_FIXEDARGS CM_FAR CM_PASCAL    /* fixed nbr of arguments function attribute            */
  211.  
  212. /* The following are all defined to allow compiling the source under C++.  These are        */
  213. /* used to define all API and handler interfaces as C functions rather than C++                 */
  214. /* functions.  Bracket each function, or group of functions, or their prototypes with        */
  215. /* CM_CFUNCTION and CM_END_CFUNCTION.  Plural versions are also defined to aid                     */
  216. /* readability.                                                                                                                                                    */
  217.  
  218. #ifdef __cplusplus
  219. #define CM_CFUNCTION             extern "C" {
  220. #define CM_CFUNCTIONS         extern "C" {
  221. #define CM_END_CFUNCTION    }
  222. #define CM_END_CFUNCTIONS    }
  223. #else
  224. #define CM_CFUNCTION
  225. #define CM_CFUNCTIONS
  226. #define CM_END_CFUNCTION
  227. #define CM_END_CFUNCTIONS
  228. #endif
  229.  
  230. /* NOTE: There is a subtle C++ semantic rule involving linkage specifications.  When a    */
  231. /*             function is declared as a C function, and that function takes a function             */
  232. /*             pointer as a parameter (e.g., in API calls like CMSetMetaHandler(), handler        */
  233. /*             addresses, etc.), then the passed function must itself be a C function!  Thus    */
  234. /*              such functions must also be bracketed with the above definitions.                            */
  235.  
  236. #endif
  237.